package com.tanhua.manager.mp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tanhua.manager.domain.AnalysisByDay;
import com.tanhua.manager.mapper.AnalysisMapper;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;

/**
 * @author liuyp
 * @date 2021/02/21
 */
@Service
public class DemoAnalysisService extends ServiceImpl<AnalysisMapper, AnalysisByDay> {

    public void testMpService(){
        //1. 查询一个
        // AnalysisByDay analysisToday = query().eq("record_date", "2021-02-21").one();
        // System.out.println(analysisToday);

        //2. 查询多个
        /*List<AnalysisByDay> analysisByDayList = query().between("record_date", "2021-01-22", "2021-02-21").list();
        for (AnalysisByDay analysisByDay : analysisByDayList) {
            System.out.println(analysisByDay);
        }*/

        //3. 查询数量
        // Integer count = query().gt("record_date", "2021-02-21").count();
        // System.out.println(count);

        //----------前3个要掌握---------------

        //4. 数据统计
        // QueryWrapper<AnalysisByDay> wrapper = new QueryWrapper<>();
        // wrapper.select("id");
        // int count = count(wrapper);
        // System.out.println(count);

        //5. 新增数据
        AnalysisByDay analysisByDay = new AnalysisByDay();
        save(analysisByDay);
        // this.baseMapper.insert();

        //6. 调用自定义的方法
        // this.baseMapper.cumulativeUsers();
    }
}
